package com.naiterui.ehp.bs.doctor.controller;

import com.naiterui.common.repository.page.PageParamVO;
import com.naiterui.common.repository.page.PageVO;
import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.doctor.service.IPAService;
import com.naiterui.ehp.bs.doctor.vo.PAMessageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * 私人消息推送处理控制类
 *
 * @version 2015年7月18日 下午7:53:17 by chenlin
 * @Description 概述
 */
@Api(tags = {SwaggerTag.DOCTOR + SwaggerTag.NOTICE_DYNAMICS})
@RequestMapping("ad/paMessage")
@Controller
public class AdPaMessageController {

    @Autowired
    private IPAService paService;

    /**
     * @param doctorId
     * @param pageParamVO
     * @param date
     *
     * @return String <返回值描述>
     *
     * @Throws 异常信息
     * @History 2015年7月18日 下午7:55:28 by chenlin
     */
    @ApiOperation("获取患者私人消息(推送消息)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "doctorId", value = "医生ID", dataType = "long", paramType = "query", required = true),
            @ApiImplicitParam(name = "date", value = "末位消息时间戳(按时间分页)", dataType = "long", paramType = "query", required = true),
    })
    @RequestMapping(value = "/findPaList", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public PageVO<PAMessageVo> findPaList(Long doctorId, PageParamVO pageParamVO, Long date) throws BusinessException {
        if (date == null) {
            date = System.currentTimeMillis();
        }
        return this.paService.findPagePaList(doctorId, pageParamVO.getPage(), pageParamVO.getNum(), new Date(date));
    }

}
